package com.kkb.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import javax.sql.DataSource;

@Configuration
public class TransactionManagerConfig {
    /**
     * 创建事务管理器对象
     */
    @Bean("transactionManager")
    public DataSourceTransactionManager createDataSourceTransactionManager(DataSource dataSource){
        //创建对象
        DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
        //配置参数(数据源)
        transactionManager.setDataSource(dataSource);
        return transactionManager;
    }
}